package com.mlnx.stream.config;

import com.mlnx.push.MlnxPushClientService;
import com.mlnx.push.TopicFactory;
import com.mlnx.push.websocket.WebsocketMlnxPushClientService;
import com.mlnx.push.websocket.WebsocketTopicFactory;
import com.mlnx.service.base.properties.MutilDeviceProperties;
import com.mlnx.service.base.properties.PushProperties;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Created by amanda.shan on 2019/10/31.
 */
@Configuration
public class DataStreamConfig {

    @Autowired
    private MutilDeviceProperties mutilDeviceProperties;

    @Bean
    public MlnxPushClientService mlnxPushService() throws Exception {

        PushProperties pushProperties = mutilDeviceProperties.getPush();

        WebsocketMlnxPushClientService websocketMlnxPushService = new WebsocketMlnxPushClientService();
        websocketMlnxPushService.init(pushProperties);

        return websocketMlnxPushService;
    }

    @Bean
    public TopicFactory topicFactory(){
        return new WebsocketTopicFactory();
    }

}
